package com.zhengke.service.cwhs;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhengke.common.dao.CommonDao;
import com.zhengke.common.object.Result;
import com.zhengke.pojo.GoodsSaleCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * *******************************
 * 创建时间：2020/1/1 22:36
 * 项目名称：tvmall-parent
 * 文件名称：GoodsSaleCountServiceImpl.java
 * 类说明：
 *
 * @author 王鑫
 * @version 1.0
 * *******************************
 */
@Service
public class GoodsSaleCountServiceImpl implements GoodsSaleCountService {
    @Autowired
    private CommonDao dao;

    @Override
    public Result querySaleCount(String startDate, String endDate, int pageNum, int size) throws Exception {
        Map<String, String> map = new HashMap<>();
        map.put("startDate", startDate);
        map.put("endDate", endDate);
        PageHelper.startPage(pageNum, size, true);
        List<GoodsSaleCount> rtnList = (List<GoodsSaleCount>) dao.findForList("goodsSaleCountMapper.querySaleCount", map);

        System.out.println(rtnList);

        PageInfo<GoodsSaleCount> pageInfo = new PageInfo<>(rtnList);

        Result rs = new Result();
        rs.setCode("0");
        rs.setCount(pageInfo.getTotal());
        rs.setData(rtnList);
        return rs;
    }

}
